import { baseUrlApi, requestClient, type Result } from '#/api/request';

/**
 * 幻灯片页面列表
 * @param params slide_id 幻灯片ID
 * @returns
 */
export const getSlideItems = (params: { slide_id: number }) => {
  return requestClient.get<Result>(baseUrlApi('/admin/slide/items'), {
    params,
  });
};

/**
 * 添加幻灯片页面
 * @param data
 * @returns
 */
export const postSlideItems = (data: {
  content?: string;
  description?: string;
  id?: number;
  image?: string;
  slide_id: number;
  target?: string;
  title?: string;
  url?: string;
}) => {
  return requestClient.post<Result>(baseUrlApi('admin/slide/items'), data);
};

/**
 * 幻灯片页面id
 * @param id 幻灯片页面id
 * @returns
 */
export const getSlideItemsInfo = (id: number) => {
  return requestClient.get<Result>(baseUrlApi(`/admin/slide/items/${id}`));
};

/**
 * 编辑幻灯片页面
 * @param id
 * @param data
 * @returns
 */
export const putSlideItems = (
  id: number,
  data: {},
) => {
  return requestClient.put<Result>(
    baseUrlApi(`/admin/slide/items/${id}`),
    data,
  );
};

/** 删除幻灯片页面 */
export const deleteSlideItems = (id: number) => {
  return requestClient.delete<Result>(baseUrlApi(`/admin/slide/items/${id}`));
};

/**
 * 切换幻灯片页面显示状态
 * @param id
 * @returns
 */
export const postSlideItemsToggle = (id: number) => {
  return requestClient.post<Result>(
    baseUrlApi(`/admin/slide/items/${id}/toggle`),
  );
};

/**
 * 设置幻灯片页面显示状态
 * @param id 幻灯片页面id
 * @param status 幻灯片页面显示状态,0:隐藏;1:显示
 * @returns
 */
export const postSlideItemsStatus = (id: number, status: number) => {
  return requestClient.post<Result>(
    baseUrlApi(`/admin/slide/items/${id}/status/${status}`),
  );
};

/**
 * 幻灯片页面排序
 * @param data
 * @returns
 */
export const postSlideItemsListOrder = (data: { list_orders: object }) => {
  return requestClient.post<Result>(
    baseUrlApi(`/admin/slide/items/list/order`),
    data,
  );
};
